<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title><{$Think.config.cfg_webname}></title>
    <link href="__CSS__/base.css" rel="stylesheet">
    <link rel="stylesheet" href="__PUBLIC__/custom/uimaker/easyui.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/custom/uimaker/icon.css">
    <style>
        #formAdd table{ width:100%;}
        #formAdd table td{ padding:5px;}
        #formAdd table td.td-left{text-align: right; padding-right: 10px;}
	</style>
</head>
<body>
<div class="container">
    <table id="cxdm"></table>
    <div id="DivAdd" class="easyui-dialog" style="width:450px;padding:10px 20px" closed="true" resizable="true" modal="true" data-options="iconCls: 'icon-add',buttons: '#dlg-buttons'">
        <form id="formAdd" method="post" novalidate="novalidate">
            <input type="hidden" id="action" name="action">
            <input type="hidden" id="id" name="curyid">
             <table>
				<tr>
					<td class="td-left" width="25%">货币名称:</td>
					<td width="75%"><input class="easyui-textbox" type="text" name="currency" data-options="required:true" style="height:30px;"></td>
				</tr>
				<tr>
					<td class="td-left">游戏名称:</td>
                    <td width="75%">
                    <select  class="easyui-combobox" name="gameid" style="width:153px;height: 30px;" required='true'>
                    <volist name="game_id" id="vo">
                        <option  value="<{$vo.gameid}>"><{$vo.game}></option>
                    </volist> 
                    </select>
                    </td>
				</tr>

                 <tr>
                    <td class="td-left">U币比例:</td>
                    <td><input class="easyui-textbox" type="text" name="ratio" data-options="required:true" style="height:30px;"></td>
                 </tr>
				<tr>
					<td class="td-left">排序:</td>
					<td><input class="easyui-numberspinner" value="1" name="orderid" data-options="increment:1,required:true" style="height:30px;"></td>
				</tr>
	          </table>
        </form>
    </div>
    <div id="dlg-buttons">
        <div style="text-align:right;">
            <a href="javascript:void(0)" class="easyui-linkbutton" id="btnAddOK" iconcls="icon-ok" onclick="btnAddOK()">确定</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#DivAdd').dialog('close')">关闭</a>
        </div>
    </div>
</div>
<div id="tb" style="padding:0 30px;">
   <div>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add"  onclick = "addCasCasdeData()">新增</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" onclick = "editCasCasdeData()">修改</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" onclick = "delCurrency()">删除</a>
   </div>
</div>

<script type="text/javascript" src="__PUBLIC__/custom/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/custom/jquery.easyui.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/custom/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">

	$(function(){
		//加载数据
        $('#cxdm').datagrid({
        	title:'货币管理',
        	width:'100%',
			height:$(window).height(),
        	fitColumns:true,
            striped: true,
            checkOnSelect:true,
            singleSelect : true,
            frozenColumns:[[
                {field:'chek',checkbox:true}
            ]],
            url:'<{:U("Currency/currencyList")}>',
            loadMsg:'数据加载中请稍后……',
            pagination: false,
            rownumbers: false,
			pageSize:10,
			toolbar:'#tb',
            columns:[[
                {field:'curyid',title: 'ID',align: 'center',sortable:"true",width:50},
                {field:'currency',title: '货币名称',align: 'center',width:100},
                {field:'game',title: '游戏名称',align: 'center',width:100},
                {field:'admin',title: '操作人',align: 'center',width:50,hidden:"ture"},
                {field:'createtime',title: '创建时间',align: 'center',width:100,hidden:"ture"},
                {field:'updatetime',title: '修改时间',align: 'center',width:100,hidden:"ture"},
                {field:'ratio',title: 'U币比例',align: 'center',width:100},
                {field:'orderid',title: '排序',align: 'center',width:50},
            ]],
        });
	});
    //修改
    function editCasCasdeData(){
        var arr=$('#cxdm').datagrid('getSelections');
        if(!arr[0]){
            $.messager.alert('提示','请选择一条数据!');
            return false;
        }
        $("#DivAdd").dialog('open').dialog('setTitle', '修改货币');
        $('#formAdd').form('load',arr[0]);
        $('#action').val("update");
    }

    function addCasCasdeData(){
        $("#DivAdd").dialog('open').dialog('setTitle', '新增货币');
        $('#formAdd').form('clear');
        $('#action').val("add");
    }
    function reload(){
        window.location.reload();
    }
    function btnAddOK() {
        $('#formAdd').form('submit',{
			url: '<{:U("Currency/msgOpt")}>',
			onSubmit: function(){
				return $(this).form('validate');
			},
			success: function(result){
				var result = eval('('+result+')');
				if (result.success){
                    if(!result.id){
                        $.messager.confirm('提示', '添加成功，继续添加?', function(r){
                            if (r){
                                $('#formAdd').form('clear');
                            }else{
                                reload();
                            }
                        });
                    }else{
                        $.messager.alert('提示','修改成功!','info',function(){
                            reload();
                        });
                    }
				} else {
					$.messager.show({
						title: '错误提示',
						msg: result.msg
					});
				}
			}
		});
    }

    function delCurrency(){
        var arr=$('#cxdm').datagrid('getSelections');
        var cc = arr[0];

        if(!cc){
            $.messager.alert('提示','请选择一条数据!');
            return false;
        }
        $.messager.confirm('提示', '确定删除?', function(r){
            if (r){
               var curyid = cc.curyid;
               $.ajax({
                    url:'<{:U("Currency/delCurrency")}>',
                    data:{
                        curyid:curyid,
                    },
                    success:function(result){
                        if (result.sta==1){
                            $.messager.alert('提示','删除成功!','info',function(){
                                reload();
                            });
                        } else {
                            $.messager.show({
                                title: '错误提示',
                                msg: result.msg
                            });
                        }
                    }
               })
            }
        });
    }

    </script>
</body>
</html>

    